<!--
 * @Descripttion: 
 * @version: 
 * @Author: ck
 * @Date: 2021-05-13 16:27:05
 * @LastEditors: ck
 * @LastEditTime: 2021-05-13 16:29:51
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let date = {
            //小于10补零  
            addZero: function (num) {
                return num > 9 ? num : "0" + num;
            }

            //格式化时间
            , formatDate: function (date, separate) {
                separate = separate || '-';
                return date.getFullYear() + separate
                    + this.addZero(date.getMonth() + 1) + separate
                    + this.addZero(date.getDate()) + ''
                    + this.addZero(date.getHours()) + ':'
                    + this.addZero(date.getMinutes()) + ':'
                    + this.addZero(date.getSeconds());
            }

            , formatDate2: function (date, separate) {
                separate = separate || '-';
                return date.getFullYear() + separate
                    + this.addZero(date.getMonth() + 1) + separate
                    + this.addZero(date.getDate()) + ''
                    + ' 00:00:00';
            }
        }
    </script>
</body>

</html>